package Java_9_15zy;

import java.lang.reflect.Constructor;
import java.lang.reflect.Field;
import java.lang.reflect.Method;
import java.util.Calendar;

public class Calender {
    public static void main(String[] args) {
        Class<Calendar> c = Calendar.class;
        System.out.println(">>>>>>>>>>>>>>类名>>>>>>>>>>>>>>>>>");
        System.out.println(c.getName());
        System.out.println(">>>>>>>>>>>>>>>>>>>父类>>>>>>>>>>>>>>>");
        System.out.println(c.getSuperclass());
        Field[] f = c.getDeclaredFields();
        System.out.println(">>>>>>>>>>>>属性>>>>>>>>>>>>>>>>>>>>>>");
        for (Field x : f) {
            System.out.println(x);
        }
        Class[] c1= c.getInterfaces();
        System.out.println(">>>>>>>>>>>>>>>>>>接口>>>>>>>>>>>>>>>>>");
        for (Class x : c1) {
            System.out.println(x);
        }
        Constructor[] c2 = c.getDeclaredConstructors();
        System.out.println(">>>>>>>>>>>>>>>>构造方法>>>>>>>>>>>>>>>");
        for (Constructor x : c2) {
            System.out.println(x);
        }
        Method[] m = c.getMethods();
        System.out.println(">>>>>>>>>>>>>>>>>>>>方法>>>>>>>>>>>>>>");
        for (Method x : m) {
            System.out.println(x);
        }

        try {
            Method method = c.getMethod("getInstance");
            Calendar a = (Calendar) method.invoke(null);
            System.out.println(a.getTime());

           Method method1= c.getMethod("set", int.class, int.class, int.class);
           method1.invoke(a,2020,01,01);
            System.out.println(a.getTime());

          Method method2= c.getMethod("get", int.class);
            System.out.println(method2.invoke(a,2));
        } catch (Exception e) {
            e.printStackTrace();
        }

    }
}
